// pages/template/tabBar/index.js
//初始化数据
function tabbarinit() {
  return [
    {
      text: "溯源",
      pagePath: "../../pages/trace/index",
      iconPath: "../../../images/scan.png",
      selectedIconPath: "../../../images/scan1.png",
      color: "#555",
      selectedColor: "#DB4453",
      active: true
    },
    {
      text: "商城",
      pagePath: "../../pages/index/index",
      iconPath: "../../../images/home.png",
      selectedIconPath: "../../../images/home1.png",
      color: "#555",
      selectedColor: "#DB4453f00",
      active: false
    },
    {
      text: "优惠",
      pagePath: "../../pages/discount/index",
      iconPath: "../../../images/find.png",
      selectedIconPath: "../../../images/find1.png",
      color: "#555",
      selectedColor: "#DB4453",
      active: false
    },
    {
      text: "分类",
      pagePath: "../../pages/sort/index",
      iconPath: "../../../images/class.png",
      selectedIconPath: "../../../images/class1.png",
      color: "#555",
      selectedColor: "#DB4453",
      active: false
    },
    {
      text: "我的",
      pagePath: "../../pages/my/index",
      iconPath: "../../../images/mine.png",
      selectedIconPath: "../../../images/mine1.png",
      color: "#555",
      selectedColor: "#DB4453",
      active: false
    }
  ]

}

/**
 * tabbar主入口
 * @param  {String} bindName 
 * @param  {[type]} id       [表示第几个tabbar，以0开始]
 * @param  {[type]} target   [当前对象]
 */
function tabbarmain(bindName = "tabdata", id, target) {
  var that = target;
  var bindData = {};
  var otabbar = tabbarinit();
  otabbar[id]['iconPath'] = otabbar[id]['selectedIconPath']//换当前的icon
  otabbar[id]['current'] = 1;
  bindData[bindName] = otabbar
  that.setData({ bindData });
}


module.exports = {
  tabbar: tabbarmain
}
